#include "qwidgetplaycanvas.h"

QWidgetPlayCanvas::QWidgetPlayCanvas(PlayData *playData)
    :AbstractPlayCanvas(playData)
{
    this->setStyleSheet("background-color: #2E64FE");
    this->setMinimumSize(playData->getSize()->width()*20, playData->getSize()->height()*20);
}

void QWidgetPlayCanvas::mousePressEvent(QMouseEvent *event)
{
    this->playData->placeMark(QPoint(event->x(), event->y()));
}

void QWidgetPlayCanvas::paintEvent(QPaintEvent *event)
{
    QPen pen(Qt::white, 2, Qt::SolidLine);
    QPainter painter(this);
    painter.setPen(pen);

    for(int i = 0; i < playData->getSize()->height()+1; i++)
    {
        painter.drawLine(0,0+20*i,playData->getSize()->width()*20, 0+20*i);
    }
    for(int i = 0; i < playData->getSize()->width()+1; i++)
    {
        painter.drawLine(0+20*i, 0, 0+20*i, playData->getSize()->height()*20);
    }


    painter.end();
}
